from tkinter import *
from tkinter import messagebox
from tkinter.filedialog import askdirectory
import readExcel

frameT = Tk()
frameT.geometry('500x200+400+200')
frameT.title('选择需要输入处理的excel文件夹')
frame = Frame(frameT)
frame.pack(padx=10, pady=10)  # 设置外边距
frame_1 = Frame(frameT)
frame_1.pack(padx=10, pady=10)  # 设置外边距
frame1 = Frame(frameT)
frame1.pack(padx=10, pady=10)
v1 = StringVar()
ent = Entry(frame, width=50, textvariable=v1).pack(fill=X, side=LEFT)  # x方向填充,靠左


# 获取文件夹目录
def fileopen():
  file_sql = askdirectory()
  if file_sql:
    v1.set(file_sql)


def match():
  print(v1.get())
  if v1.get():
    readExcel.read_excel(v1.get())
    messagebox.showinfo(title='完成', message='输出目录:' + v1.get() + '/新版文件')
  else:
    messagebox.showinfo(title='错误', message='请先选择目录')


btn = Button(frame, width=20, text='选择文件夹', font=("宋体", 14), command=fileopen).pack(fil=X, padx=10)
ext = Button(frame1, width=10, text='运行', font=("宋体", 14), command=match).pack(fill=X, side=LEFT)
etb = Button(frame1, width=10, text='退出', font=("宋体", 14), command=frameT.quit).pack(fill=Y, padx=10)
frameT.mainloop()

